<?php
namespace Modules\ShopApi\Http\Controllers\v1;
use Illuminate\Http\Request;
use Modules\ShopApi\Http\Requests\IDMustBePositiveIntRequest;
use Modules\ShopApi\Http\Requests\PidRequest;
use Modules\ShopApi\Http\Requests\AddSiteRequest;
use Modules\ShopApi\Http\Requests\EditSiteRequest;
use Modules\ShopApi\Models\ShopSite as ShopSiteModel;
use Modules\ShopApi\Models\Area as AreaModel;
class SiteController extends CommonController
{
	/**
	 * @name  获取省市区
	 * @method  GET
	 * @param pid 上级id（pid=0表示获取顶级）
	 * @return  JSON
	 */
    public function get_area(PidRequest $request)
    {
        return (new AreaModel())->get_area($request->get('pid'));
    }
	/**
	 * @name  添加地址
	 * @method  POST
	 * @param name 姓名
	 * @param phone 手机号
	 * @param province_id 省ID
	 * @param city_id 市ID
	 * @param county_id 区/县ID
	 * @param detailed_address 详细地址
	 * @param status 是否默认：1=是 0=否
	 * @return  JSON
	 */ 
    public function add_site(AddSiteRequest $request)
    {
        return (new ShopSiteModel())->add_site($request->all());
    }
	/**
	 * @name  地址列表
	 * @method  GET
	 * @return  JSON
	 */ 
    public function site_list(Request $request)
    {
        return (new ShopSiteModel())->site_list();
    }
	/**
	 * @name  获取我的收获地址
	 * @method  GET
	 * @return  JSON
	 */ 
    public function get_user_site()
    {
        return (new ShopSiteModel())->get_user_site();
    }
	/**
	 * @name  地址编辑页面数据
	 * @method  GET
	 * @param  id 地址id
	 * @return  JSON
	 */ 
    public function get_list_info(IDMustBePositiveIntRequest $request)
    {
        return (new ShopSiteModel())->get_list_info($request->get('id'));
    }
	/**
	 * @name  地址编辑
	 * @method  PUT
	 * @param  id 地址id
	 * @param name 姓名
	 * @param phone 手机号
	 * @param province_id 省ID
	 * @param city_id 市ID
	 * @param county_id 区/县ID
	 * @param detailed_address 详细地址
	 * @param status 是否默认：1=是 0=否
	 * @return  JSON
	 */ 
    public function edit_site(EditSiteRequest $request)
    {
        return (new ShopSiteModel())->edit_site($request->all());
    }
	/**
	 * @name  地址删除
	 * @method  DELETE
	 * @param  id 地址id
	 * @return  JSON
	 */ 
    public function delete_site(IDMustBePositiveIntRequest $request)
    {
        return (new ShopSiteModel())->delete_site($request->get('id'));
    }
}
